package cn.duhengkui.national.valuelist.core.data.util;

import java.lang.reflect.Method;
import java.sql.JDBCType;


/**   
 * <table border="1">
 *	<tr><td>包名称：</td><td>cn.duhengkui.national.valuelist.core.data.util</td></tr>
 *	<tr><td>类名称：</td><td>EntityAttribute</td></tr>
 *	<tr><td>类描述：</td><td>Entity实体对象属性</td></tr>
 *	<tr><td>创建人：</td><td>杜恒奎</td></tr>
 *  <tr><td>创建时间：</td><td>2018年6月7日/下午3:12:13</td></tr> 
 *  <tr><td>版本：</td><td>1.0.0</td></tr>
 * </table>   
 *     
 */
public class EntityAttribute {

	private boolean pk;
	
	private boolean notNull;
	
	private String name;
	
	private String attributeName;
	
	private int length;
	
	private int precision;
	
	private int scale;
	
	private Method setterMethod;
	
	private boolean noInsert;
	
	private boolean noUpdate;
	
	private JDBCType jdbcType;	
	
	public static EntityAttribute createByColumnName(String columnName) {
		EntityAttribute attribute = new EntityAttribute();
		attribute.setName(columnName);
		return attribute;
	}
	
	public static EntityAttribute createByAttributeName(String attributeName) {
		EntityAttribute attribute = new EntityAttribute();
		attribute.setAttributeName(attributeName);
		return attribute;
	}
	
	boolean isCurrentByColunmnName(String columnName) {
		return name.equalsIgnoreCase(columnName);
	}
	
	boolean isCurrentByAttributeName(String attributeName) {
		return attributeName.equalsIgnoreCase(attributeName);
	}
	
	public boolean isPk() {
		return pk;
	}

	public void setPk(boolean pk) {
		this.pk = pk;
	}

	public boolean isNotNull() {
		return notNull;
	}

	public void setNotNull(boolean notNull) {
		this.notNull = notNull;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public int getPrecision() {
		return precision;
	}

	public void setPrecision(int precision) {
		this.precision = precision;
	}

	public int getScale() {
		return scale;
	}

	public void setScale(int scale) {
		this.scale = scale;
	}

	public void setAttributeName(String attributeName) {
		this.attributeName = attributeName;
	}
	
	public String getterName() {
		return "get" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
	}
	
	public String setterName() {
		return "set" + attributeName.substring(0, 1).toUpperCase() + attributeName.substring(1);
	}

	public Method getSetterMethod() {
		return setterMethod;
	}

	public void setSetterMethod(Method setterMethod) {
		this.setterMethod = setterMethod;
	}

	/**
	 * @return the noInsert
	 */
	public boolean isNoInsert() {
		return noInsert;
	}

	/**
	 * @param noInsert the noInsert to set
	 */
	public void setNoInsert(boolean noInsert) {
		this.noInsert = noInsert;
	}

	/**
	 * @return the noUpdate
	 */
	public boolean isNoUpdate() {
		return noUpdate;
	}

	/**
	 * @param noUpdate the noUpdate to set
	 */
	public void setNoUpdate(boolean noUpdate) {
		this.noUpdate = noUpdate;
	}

	/**
	 * @return the attributeName
	 */
	public String getAttributeName() {
		return attributeName;
	}

	public JDBCType getJdbcType() {
		return jdbcType;
	}

	public void setJdbcType(JDBCType jdbcType) {
		this.jdbcType = jdbcType;
	}
	
	
	
}